package com.hsteach.web.controller.equipment;

import com.hsteach.common.core.controller.BaseController;
import com.hsteach.common.core.domain.AjaxResult;
import com.hsteach.common.core.page.TableDataInfo;
import com.hsteach.dao.domain.equipment.EquipmentRepair;
import com.hsteach.service.equipment.EquipmentRepairService;
import com.hsteach.web.controller.equipment.dto.AssignDto;
import com.hsteach.web.controller.equipment.dto.EquipmentPublicDto;
import com.hsteach.web.controller.equipment.dto.EquipmentRepairDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "设备报修信息", tags = "设备报修信息")
@RequestMapping("/equipment/repair")
public class EquipmentRepairController extends BaseController {

    @Autowired
    private EquipmentRepairService equipmentRepairService;

    /**
     * 查询设备报修列表
     * @param
     * @return
     */

    @ApiOperation("查询设备报修列表")
    @PostMapping("/list")
    public TableDataInfo<EquipmentRepair> list(@RequestBody EquipmentPublicDto equipmentPublicDto ){
        return getDataTable( equipmentRepairService.queryList(equipmentPublicDto));
    }

    /**
     * 查询设备报修详情
     * @param id
     * @return
     */
    @ApiOperation("查询设备报修详情")
    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id ){
        return success(equipmentRepairService.queryDetail(id));
    }

    /**
     * 新增报修信息
     * @param equipmentRepairDto
     * @return
     */
    @ApiOperation("新增报修信息")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody EquipmentRepairDto equipmentRepairDto){
        return success(equipmentRepairService.add(equipmentRepairDto));
    }

    /**
     * 指派维修人员
     * @param dto
     * @return
     */
    @ApiOperation("指派维修人员")
    @PostMapping("/assign")
    public AjaxResult assign(@RequestBody AssignDto dto){
        return toAjax(equipmentRepairService.assign(dto));
    }
}
